export default {
  // 防抖函数

  // 提示信息工具

  // 取窗口可视范围高度
  getClientHeight:()=>{
    let clientHeight:number = 0;
    if(document.body.clientHeight&&document.documentElement.clientHeight)
    {
      clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
    }else{
      clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
    }
    return clientHeight;
  },

  //获取元素的高度
  getDivHeight:(ele:any)=>{
    return ele.clientHeight
  },

  //获取表格高度
  getTableHeight: (cardHeiht:number,arr:any[])=>{
    let sum:number = 0
    for(let i = 0;  i<arr.length;i++){
      sum += arr[i].clientHeight
    }
    return cardHeiht - sum - (arr.length+1) * 10 - 40;
  },

  // 把指定时间格式化成指定格式
	FormatByTypeTime :(time:any, format: string = 'yyyy-MM-dd HH:mm:ss') => {
		let currentTime: string | Date = new Date(new Date(time as any).getTime());
		const currentHour = currentTime.getHours() < 10 ? ('0' + currentTime.getHours()) : (currentTime.getHours())
		const currentMin = currentTime.getMinutes() < 10 ? ('0' + currentTime.getMinutes()) : currentTime.getMinutes()
		const currentSec = currentTime.getSeconds() < 10 ? ('0' + currentTime.getSeconds()) : currentTime.getSeconds()
		const currentYear = currentTime.getFullYear();
		const currentMonth = currentTime.getMonth() < 9 ? ('0' + (currentTime.getMonth() + 1)) : (currentTime.getMonth() + 1);
		const currentDay = currentTime.getDate() < 10 ? ('0' + currentTime.getDate()) : currentTime.getDate();
		switch(format) {
			case 'yyyy-MM-dd HH:mm:ss':
				currentTime = `${currentYear}-${currentMonth}-${currentDay} ${currentHour}:${currentMin}:${currentSec}`;
				break
			case 'yyyy-MM-dd HH:mm':
				currentTime = `${currentYear}-${currentMonth}-${currentDay} ${currentHour}:${currentMin}`;
				break
			case 'yyyy-MM-dd':
				currentTime = `${currentYear}-${currentMonth}-${currentDay}`;
				break
			case 'yyyy-MM':
				currentTime = `${currentYear}-${currentMonth}`;
				break
			case 'MM-dd':
				currentTime = `${currentMonth}-${currentDay}`;
				break
			case 'yyyy':
				currentTime = `${currentYear}`;
				break
		}
		return currentTime;
  }
}
